#include <SGE.h>
using namespace SGE;
#include "PlayState.h"
#include "FrontEndState.h"
#include "GameContext.h"
#include "GameOverState.h"
//global variable
GameContext newGameState;
GameState* currentState = nullptr;
NextStates nextState = Frontend;
void SGE_Initialize()
{
}

void SGE_Terminate()
{
}


bool SGE_Update(float deltaTime)
{
	if(nextState != None)
	{
		if(currentState!=nullptr)
		{
			currentState->Unload();
			delete currentState;
		}

		switch (nextState)
		{
			case Frontend:
				currentState = new FrontEndState(newGameState);
				break;
			case Gameplay:
				currentState = new PlayState(newGameState);
				break;
			case GameOver:
				currentState = new GameOverState(newGameState);
				break;
			case Quit:
				break;
			default:
				break;
		}
		currentState->Load();
	}

	nextState = currentState->Update(deltaTime);

	//quit
	if(nextState == Quit)
	{
		currentState->Unload();
		delete currentState;
		return true;
	}
	
	return false;
}

void SGE_Render()
{
	currentState->Render();
}


